﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using WP7Client.Classes;
using GalaSoft.MvvmLight.Command;
using WP7Client.Helpers;
using WP7Client.ServerManager;

namespace WP7Client.Controller
{
    public class SearchController : BaseController
    {
        private SearchFilter filter;

        public SearchController()
        {
            filter = new SearchFilter();
            SearchCommand = new RelayCommand(DoSearch);
        }

        public ICommand SearchCommand
        {
            get;
            internal set;
        }

        public SearchFilter Filter
        {
            get { return filter; }
        }

        /// <summary>
        /// Zoek naar gebruikers aan de hand van velden in hun profiel
        /// </summary>
        private void DoSearch()
        {
            if (!filter.IsFilterValid)
            {
                GlobalHelper.ShowMessage("Error", "Please specify any query criteria.");
                return;
            }
            else
            {
                ControllerHelper.SearchResultController.Search(0, 0, Filter);
                NavigationHelper.NavigateTo("/UserInterface/Pages/SearchResultPage.xaml");
            }
        }
    }
}
